package com;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "RequestServlet", value = "/RequestServlet")
public class RequestServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        System.out.println("URI=>"+request.getRequestURI());
        //获取请求的统一资源定位符（绝对路径）
        System.out.println("URI =>"+request.getRequestURL());
        //获取客户端IP地址
        /**
         * 在IDEA中 使用localhost访问时，得到的客户端IP地址是===》
         */
        System.out.println("客户端 ip地址 =>"+request.getRemoteHost());
        //获取请求头
        System.out.println("请求头 =>"+request.getHeader("User-Agent"));
        //获取请求的方式
        System.out.println("请求方式："+request.getMethod());
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
